﻿/**
 * 表单提交
 * @@param posturl
 * @@param backurl
 */
function savePost(posturl, backurl) {
    var oldPass = $("#OldPass").val();
    var newPass = $("#NewPass").val();
    var confirmPass = $("#ConfirmPass").val();
    var encrypt = new JSEncrypt();
    encrypt.setPublicKey($("#publicKey").val());
    var encytOld = encrypt.encrypt(oldPass);
    var encytNew = encrypt.encrypt(newPass);
    var encytConfirm = encrypt.encrypt(confirmPass);
    $.ajax({
        url: posturl,
        type: "post",
        data: { "OldPass": encytOld, "NewPass": encytNew, "ConfirmPass": encytConfirm },
        success: function (rs) {
            var iconMsg = 2;
            if (rs.status == 1) {
                iconMsg = 1;
            }
            layer.open({
                title: "提示",
                icon: iconMsg,
                content: rs.msg,
                yes: function () {
                    layer.closeAll();
                    if (rs.status == 1) {
                        parent.location.href = backurl;
                    }
                }
            });
        },
        error: function (rs) {
            layer.msg("网络错误，保存失败！", { icon: 2 });
        }
    });
}